//
//  ScanSearchDemoViewController.swift
//  ZZUIDemo
//
//  Created by 张文晏 on 2018/11/20.
//  Copyright © 2018 Newcoretech. All rights reserved.
//

import UIKit
import ZZUI

class ScanSearchDemoViewController: UIViewController {
    
    @IBOutlet var searchCodeLabel: UILabel!
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        
        navigationController?.navigationBar.tintColor = UINavigationController().navigationBar.tintColor
    }
    
    func setupNavigationBar() {
        navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil)
        navigationController?.navigationBar.setBackgroundImage(nil, for: .default)
        navigationController?.navigationBar.isTranslucent = true
        navigationController?.navigationBar.shadowImage = nil
    }
    
    @IBAction func scanAction(_ sender: UIButton) {
        let scanVC = ScanViewController()
        scanVC.analyseClosure = { code in
            return .success(finishClosure: {
                self.navigationController?.popViewController(animated: true)
                self.searchCodeLabel.text = code
            })
        }
        navigationController?.pushViewController(scanVC, animated: true)
    }
    
}
